package org.yefei.homeworkday18;

/*2:修改前面老师那题：
老师有年龄，学校，姓名的属性，有上课和自我介绍的方法，如果年龄少于22岁，抛出异常。*/
public class Teacher {
	private int age;
	private String school;
	private String name;

	public int getAge() {
		return age;
	}

	public void setAge(int age) throws Exception {
		if (age < 22) {
			throw new ArithmeticException("年龄不小于22");
		}
		this.age = age;
	}

	public String getSchool() {
		return school;
	}

	public void setSchool(String school) {
		this.school = school;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void teach() {
		System.out.println("老师讲课！");
	}

	@Override
	public String toString() {

		return "我叫" + name + "是" + school + "的一名老师，" + "今年" + age + "岁";
	}

}
